use clap::Parser;
use synapse_server::args::Args;
use synapse_server::server::Server;
use std::process::id;
use std::sync::Arc;

#[tokio::main]
async fn main() {

    let args = Arc::new(Args::parse());
    std::env::set_var("RUST_LOG", &args.loglevel);
    env_logger::init();

    server_info(args.clone());
    let server = Server::new(args.clone());
    server.start().await;
}

fn server_info(args: Arc<Args>) {
    let pid = id();
    let version = env!("CARGO_PKG_VERSION");
    let pattern = format!(r#"
       ___ _   _ ____   ____ ____   ___  ____ 
      /___) | | |  _ \ / _  |  _ \ /___)/ _  )
     |___ | |_| | | | ( ( | | | | |___ ( (/ / 
     (___/ \__  |_| |_|\_||_| ||_/(___/ \____)
          (____/            |_|               

     Synapse {}

     Introduce: A high-performance vector database

     Bind: {}  PID: {}
    
    "#, version, args.port, pid);
    println!("{}", pattern);
}